package collections;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Random;

//班级里有n个学生，学生属性；姓名，年龄，性别
//实现随机点名
public class Test1 {
    public static void main(String[] args) {
        //创建集合
        ArrayList<String> list = new ArrayList<>();

        //存入数据
        Collections.addAll(list,"君安肆","小叶榕","沙耶松","娜米玉","帕姆","徐雅雯","涵江","许瑶","张天舒");

        //随机
        //方法一
        Random random = new Random();
        int index = random.nextInt(list.size());
        System.out.println(list.get(index));

        //方法二
        Collections.shuffle(list);
        System.out.println(list.get(0));
    }
}
